<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport"
        content="width=device-width, initial-scale=1.0" />
<meta name="HandheldFriendly" content="true" />
<title>Sample</title>
</head>
<body style="margin: 0;padding: 0; text-align:left;">
<div id="info" style="width:100%; min-height:100px; background-color:#A7BD5B;"></div>
<div id="obj_a" style="width:50px; height:50px; background-color:#DC574E; position:absolute; left:100px; top:100px;">A</div>
<div id="obj_b" style="width:50px; height:50px; background-color:#DC574E; position:absolute; left:170px; top:100px;">B</div>

<script>
function getScreenOrientation() 
{ 
    // 先判断目前浏览器是否支持：orientation的属性
    if (window.orientation) { 
        if (window.orientation == 90 || window.orientation == -90) 
            return "landscape"; 
        else return "portrait"; 
    } 
    // 如果不支持orientation属性
    // 改用screen.width与screen.height来比较
    else { 
        if(window.screen){
           var width = screen.width;
           var height = screen.height;
           if (width > height) {
                return "landspcape";
           } else {
                return "portrait";
           }
        }
    }
    return "无法确定";
}
// 把下面三个都写上以保持最大的兼容性
document.body.onload = getScreenOrientation;
window.onorientationchange = getScreenOrientation;
setTimeout(getScreenOrientation, 5000);
</script>
</body>
</html>
